//
// Created by Administrator on 2020/7/1.
//第三章:函数——get:
//重载函数
//系统函数

// 第三章:实验
//例3:分别编写四个同名函数max1,实现函数重载:
//可分别求取两个整数、三个整数、两个双精度数、三个双精度数的最大值。在main()函数中测试函数功能。

#include <iostream>
#include <cmath>
using namespace std;
/*
int max1(int x,int y);//两个整数的最大值
int max1(int x,int y,int z);//三个整数的最大值
double max1(double x,double y);//两个双精度数的最大值
double max1(double x,double y,double z);//三个双精度数的最大值

int max1(int x,int y)//两个整数的最大值
{
    if(x==y)
        return x;
    else if(x>=y)
        return x;
    else
        return y;
}

int max1(int x,int y,int z)//三个整数的最大值
{
    return max1(max1(x,y),z);
}

double max1(double x,double y)//两个双精度数的最大值
{
    if(abs(x-y)<1e-10)
        return x;//判断两浮点是否相等的常见处理方式
    else if(x>=y)
        return x;
    else
        return y;
}

double max1(double x,double y,double z)//三个双精度数的最大值
{
    return(max1(x,y),z);
}

int main()
{
    int a,b,c;
    double m,n,l;

    cout<<"Enter int a:";
    cin>>a;
    cout<<"Enter int b:";
    cin>>b;
    cout<<"Enter int c:";
    cin>>c;

    cout<<"\n";

    cout<<"max of"<<a<<"and"<<b<<"is"<<max1(a,b)<<endl;
    cout<<"max of"<<a<<","<<b<<"and"<<c<<"is"<<max1(a,b,c)<<endl;
    cout<<"\n\n";

    cout<<"Enter double m:";
    cin>>m;
    cout<<"Enter double n:";
    cin>>n;
    cout<<"Enter double l:";
    cin>>l;

    cout<<"\n";

    cout<<"max of"<<m<<"and"<<m<<"is"<<max1(m,n)<<endl;
    cout<<"max of"<<m<<","<<n<<"and"<<l<<"is"<<max1(m,n,l)<<endl;
    return 0;
}
*/

//例4:在main()函数中提示输入两个整数x,y,使用cin语句得到x,y的值，调用pow(x,y)函数计算x的y次幂的结果,再显示出来:
//注意:包含cmath库
int main()
{
    int x,y;
    cout<<"Enter int x:";
    cin>>x;

    cout<<"Enter int y:";
    cin>>y;

    cout<<"\n";

    cout<<"x="<<x<<"\t";
    cout<<"y="<<y<<"\n";
    cout<<"pow(x,y)="<<pow(x,y);

    return 0;
}